home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 90 / CD Actual 90.iso / Software3D / K-3D / k3d-0.4.2.1 / shaders / k3d_paintedplastic.sl < prev    next >
Encoding:
Text File  |  2004-07-23  |  1.2 KB  |  48 lines

  1. /* paintedplastic.sl - Standard texture map surface for RenderMan Interface.
  2.  * (c) Copyright 1988, Pixar.
  3.  *
  4.  * The RenderMan (R) Interface Procedures and RIB Protocol are:
  5.  *     Copyright 1988, 1989, Pixar.  All rights reserved.
  6.  * RenderMan (R) is a registered trademark of Pixar.
  7.  *
  8.  * DESCRIPTION:
  9.  *    Apply a texture map to a plastic surface, indexing the texture
  10.  *    by the s,t parameters of the surface.
  11.  *
  12.  * PARAMETERS:
  13.  *    Ka, Kd, Ks, roughness, specularcolor - the usual meaning.
  14.  *    texturename - the name of the texture file.
  15.  *
  16.  */
  17.  
  18. surface k3d_paintedplastic(
  19.     float Ka = 1.0;
  20.     float Kd = 0.5;
  21.     float Ks = 0.5;
  22.     float roughness = 0.1;
  23.     color specularcolor = 1.0;
  24.     string texturename = "";
  25.     float s0 = 0.0;
  26.     float s1 = 1.0;
  27.     float t0 = 0.0;
  28.     float t1 = 1.0;
  29.     )
  30. {
  31.     color Ct = color(1, 1, 1);
  32.     float Ot = 1;
  33.     
  34.     if(texturename != "")
  35.         {
  36.             float ss = mix(s0, s1, s);
  37.             float tt = mix(t0, t1, t);
  38.             
  39.             Ct = color texture(texturename, ss, tt);
  40.             Ot = float texture(texturename[3], ss, tt);
  41.         }
  42.  
  43.     normal Nf = faceforward(normalize(N), I);
  44.     vector V = -normalize(I);
  45.     Oi = Os * Ot;
  46.     Ci = Oi * Cs * Ct * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness);
  47. }
  48.